﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace IRM.Messaging.Service
{
    public partial class ApplicationQueue : ServiceBase
    {
        private MessageHandler handler;
        private IDbConnection connection;

        public ApplicationQueue()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            connection = new System.Data.SqlClient.SqlConnection(Properties.Settings.Default.ApplicationQueueConnectionString);
            handler = new MessageHandler(connection);
            handler.StartHandleAllMessages();
        }

        protected override void OnStop()
        {
            handler.StopHandleAllMessages();
            connection.Dispose();
        }

        protected override void OnPause()
        {
            handler.StopHandleAllMessages();
        }

        protected override void OnContinue()
        {
            handler.StartHandleAllMessages();
        }
    }
}
